设置nginx列表下载文件并设置密码的配置 |
您所在的位置:网站首页 › nginx 配置查看 › 设置nginx列表下载文件并设置密码的配置 |
cd /etc/nginx/conf.d 创建密码文件和用户密码 htpasswd -c .htpasswd fileuser_chenshifei 输入密码 vim default.conf 配置文件 server { listen 80 default_server; #listen [::]:80 default_server; server_name _; #root /usr/share/nginx/html; root /var/www/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { #列表 autoindex on; #隐藏真实大小,以M或G显示 autoindex_exact_size off; #显示时间 autoindex_localtime on; #设置密码文件 auth_basic "input you user name and password"; auth_basic_user_file /etc/nginx/conf.d/.htpasswd; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } 将文件包放在/var/www/html下 nginx -s reload 访问ip:80/ 输入密码就可以下载了 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |